import time

from selenium.webdriver.common.by import By

from common.Utills import BlogDriver


#博客编辑页面测试
class BlogEdit:
    url=""
    driver = ""

    def __init__(self):
        self.url = "http://8.137.19.140:9090/blog_list.html"
        self.driver = BlogDriver.driver
        self.driver.get(self.url)

    def EditSucTestByLogin(self):
        tme = len(self.driver.find_elements(By.XPATH, '/html/body/div[2]/div[2]/div'))
        self.driver.get("http://8.137.19.140:9090/blog_edit.html")
        self.driver.find_element(By.CSS_SELECTOR,"#title").send_keys("自动化测试")
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
        time.sleep(2)
        actual= len(self.driver.find_elements(By.XPATH,'/html/body/div[2]/div[2]/div'))
        if(actual>tme):
            print("发布成功")
        else:
            print("发布失败")
